package com._51doit.spark02

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object ActionTest {

  def main(args: Array[String]): Unit = {

    val conf: SparkConf = new SparkConf()
      .setMaster("local[*]")
      .setAppName(this.getClass.getSimpleName)

    val sc: SparkContext = new SparkContext(conf)

    val rdd: RDD[Int] = sc.makeRDD(List(1,4,5,8,3,9),2)

    val d = (i:Int,it:Iterator[Int])=>it.map(t => s"v=$t,p=$i")


    val res1: Array[String] = rdd.mapPartitionsWithIndex(d).collect


   // res1.toList.foreach(println)

    val res2: RDD[Int] = rdd.map(_*3)


    val res3: RDD[Int] = res2.filter(_%2==0)




    res3.foreach(println)

  }




}
